package com.cskaoyan.controller;

import com.cskaoyan.bean.configInfo.ExperssVo;
import com.cskaoyan.bean.configInfo.MallVo;
import com.cskaoyan.bean.configInfo.OrderVo;
import com.cskaoyan.bean.configInfo.WxVo;
import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 
 * 创建日期: 2022/05/05 20:24
 * @author wangyonghong
 */
@RestController
@RequestMapping("admin/config")
public class ConfigController {
    @Autowired
    ConfigService configService;

    @GetMapping(value = "mall")
    public BaseRespVo getMall() {
        MallVo mallVo = configService.query();
        if(mallVo==null){return null;}
        return  BaseRespVo.ok(mallVo);
    }
    @PostMapping(value = "mall")
    public BaseRespVo postMall(@RequestBody MallVo mallVo) {
      configService.update(mallVo);
      return  BaseRespVo.ok(null);

    }
    @GetMapping(value = "express")
    public BaseRespVo getExpress() {
        ExperssVo experssVo = configService.queryExpress();
        if(experssVo==null){return null;}
        return  BaseRespVo.ok(experssVo);
    }
    @PostMapping(value = "express")
    public BaseRespVo postExpress(@RequestBody  ExperssVo experssVo ) {
        configService.updateExpress(experssVo);
        return  BaseRespVo.ok(null);
    }
    @GetMapping(value = "order")
    public BaseRespVo getOrder() {
        OrderVo orderVo = configService.queryOrder();
        if(orderVo==null){

            return null;}
        return  BaseRespVo.ok(orderVo);
    }
    @PostMapping(value = "order")
    public BaseRespVo postOrder(@RequestBody      OrderVo orderVo ) {
        configService.updateOrder(orderVo);
        return  BaseRespVo.ok(null);
    }
    @GetMapping(value = "wx")

        public BaseRespVo getWx() {
        WxVo wxVo = configService.queryWx();
        if(wxVo==null){
            return null;}
        return  BaseRespVo.ok(wxVo);
    }
    @PostMapping(value = "wx")
    public BaseRespVo postWx(@RequestBody WxVo wxVo ) {
        configService.updateWx(wxVo);
        return  BaseRespVo.ok(null);
    }
}
